<?php
/**
 * Created by PhpStorm.
 * User: Lin
 * Date: 2017/3/18 0018
 * Time: 上午 11:05
 */
Class PaymentAction extends CommonAction {
    public function showList(){
        $payment=M("payment")->select();
        $this->payment=$payment;
        $this->display();
    }
    
    public function addPayment(){
        $this->display();
    }
    
    public function editPayment(){
        $id=$_GET['id'];
        $this->payment=M('payment')->find($id);
        $this->display('addPayment');
    }
    
    public function deletePayment(){
        $id=$_GET['id'];
        if(M('payment')->delete($id)){
            $this->success('删除成功');
        }else{
            $this->error('删除失败');
        }
    }
    
    //运行保存
    public function runSave(){
        $add=$_GET['add'];
        $payment=$_POST;
        if($add){
            $result=M('payment')->add($payment);
        }else{
            $result=M('payment')->save($payment);
        }
        $val=$add?'添加':'编辑';
        if($result){
            $this->success($val.'成功',U(GROUP_NAME.'/Payment/showList'));
        }else{
            $this->error($val.'失败');
        }
    }
}